import sys
import numpy as np 
from PySide6 import QtCore
from PySide6.QtWidgets import QApplication, QMainWindow, QTableView
from PySide6.QtCore import Qt
from PySide6.QtGui import QColor, QIcon

class TableView(QtCore.QAbstractTableModel):
    def __init__(self, data):
        super().__init__()

        self._data = data

    def data(self, index, role):
        if role == Qt.DisplayRole:
            value = self._data[index.row()][index.column()]
            return str(value)
    
    def rowCount(self, index):
        return self._data.shape[0]
    
    def columnCount(self, index):
        return self._data.shape[1]


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("TableView Numpy")

        data = np.array([[1,2,3], [4,5,6], [6,7,8], [2, 3, 2]])
        self.table = QTableView()
        self.model = TableView(data)
        self.table.setModel(self.model)

        self.setCentralWidget(self.table)
        self.setGeometry(600, 100, 400, 200)

app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
